import { defineStore } from "pinia";
import { ref } from "vue";

export const useTokenStore = defineStore("token",() =>{
    //定义token
    const token = ref("");
    //设置token
    function setToken(token){
        this.token = token;
        localStorage.setItem("token",this.token);
    }
    //获取token
    function getToken(){
        
        this.token = localStorage.getItem("token")
        return this.token
    }
    //曝露变量及方法
    return {token,setToken,getToken}
})